/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package serverudp;
import java.io.*;
import java.net.*;
/**
 *
 * @author Minh
 */
public class ServerUDP {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        try {
            String stSend;
            String stRcv;
            boolean sExit,rExit;
            int port = 1234 ;  //port socket used to listen
            //khoi tao socket
            DatagramSocket socket=new DatagramSocket(port);
            
                //Nhan thong diep tu Client
                byte []rcvbuf = new byte[1024];
                //Tao DatagramPacket de nhan data
                DatagramPacket rcvpkt = new DatagramPacket(rcvbuf,rcvbuf.length);
                //Goi ham nhan DatagramPacket
                socket.receive(rcvpkt);
                stRcv = new String(rcvpkt.getData(),0,rcvpkt.getLength());
                System.out.println("Client: "+ stRcv);

                /******************************************************/

         
            //dong ket noi
            socket.close();
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
}
